1 <?php
2 session_start();
3 if(isset($_SESSION['user']))
4 {
5
6 }
7 else{
8 echo"<script>location.href='login.html'</script>";
9 }
10 ?>
11 <!doctype html>
12 <html>
13 <head>
14 <title>Birds </title>
15 <style>
16 body {
17 margin: 0;
18 font-family: Arial, Helvetica, sans-serif;
19 background: #484848;
20 }
21 .topnav {
22 overflow: hidden;
23 background-color:rgba(44, 130, 201, 1);
24 height: 70px;
25 border: 3px solid #3333ff
26 }
27
28 .topnav a {
29 float: left;
30 color: #f2f2f2;
31 text-align: center;
32 padding: 14px 16px;
33 text-decoration: none;
34 font-size: 35px;
35 font-weight: bold;
36 }
37
38 .topnav-right {
39 float: right;
40 }
41 fieldset {
42 background: #FAFAFA;
43 padding: 10px;
44 margin:auto;
45 max-width:450px;
46 box-shadow: 1px 1px 25px rgba(0, 0, 0, 0.35);
47 border-radius: 10px;
48 border: 6px solid rgba(44, 130, 201, 1);
49
50
51 }
52
53
54
55 </style>
56 </head>
57 <body>
58 <div class="topnav">
59 <a class="active" href="home.html"><img src="ic_add_pet.png"></a>
60 <a href="birds.php">Birds</a>
61 <div class="topnav-right">
62 <a href="logout.php">logout</a>
63 </div>
64 </div>
65
66 <form>
67 <button type="submit" formaction="birds.php" style="margin:15px;height: 30px;width: 100px;cursor:pointer;border-radius:15px;
68 border: 3px solid #3333ff;background-color:rgba(44, 130, 201, 1);color:#f2f2f2;font-size:17px;">Back</button>
69 </form>
70 <form method="post" action="birdsadd.php">
71 <fieldset>
72 <input type="text" name="id" placeholder=" Enter pet_id" style="width:100%;height:30px;
73 border: 2px solid rgba(44, 130, 201, 1); border-radius:3px; background:transparent;" required>
74 <br><br>
75 <input type="text" name="category" placeholder=" Enter pet_category" style="width:100%;height:30px;
76 border: 2px solid rgba(44, 130, 201, 1); border-radius:3px; background:transparent;" required>
77 <br><br>
78 <input type="text" name="type" placeholder=" Enter bird type" style="width:100%;height:30px;
79 border: 2px solid rgba(44, 130, 201, 1); border-radius:3px; background:transparent;" required>
80 <br><br>
81 <select name="noise" style="width:100%;height:30px;
82 border: 2px solid rgba(44, 130, 201, 1); border-radius:3px; background:transparent;">
83 <option value="low">low</option>
84 <option value="moderate">moderate</option>
85 <option value="high">high</option>
86 </select>
87 <br><br>
88 <input type="number" name="cost" placeholder=" Enter cost" style="width:100%;height:30px;
89 border: 2px solid rgba(44, 130, 201, 1); border-radius:3px; background:transparent;" min="0" required>
90 <br><br>
91 <input type="submit" name="submit" value="save" style="width:100%;height:30px;
92 border: 2px solid rgba(44, 130, 201, 1); border-radius:3px; cursor:pointer;background-color:rgba(44, 130, 201, 1)"> 
93 </fieldset>
94 </form>
95 </body>
96 </html>
97 <?php
98 if(isset($_POST["submit"]))
99 {
100 // define variables and set to empty values
101 $servername = "localhost";
102 $username = "root";
103 $password = "";
104 $dbname = "Petshop_management";
105
106 // Create connection
107 $conn = new mysqli($servername, $username, $password, $dbname);
108 // Check connection
109 if ($conn->connect_error) {
110 die("Connection failed: " . $conn->connect_error);
111 }
112 //echo " CONNECTION ESTABLISHED \r\n";
113 //echo " INSERTION IN PROCESS";
114 $id = $_POST["id"];
115 $category = $_POST["category"];
116 $type= $_POST["type"];
117 $noise = $_POST["noise"];
118 $cost = $_POST["cost"];
119
120
121
122
123 $sql = "INSERT INTO pets( pet_id,pet_category,cost)
124 VALUES ('$id','$category','$cost');
125 INSERT INTO birds(pet_id,type,noise)
126 VALUES('$id','$type','$noise')";
127 if ($conn->multi_query($sql) == TRUE) {
128 echo'<div>
129 <h1 style="color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">New record of id='
130 .$id. ' inserted successfully</h1>
131 </div>';
132 } else {
133 echo "Error: " . $sql . "<br>" . $conn->error;
134 }
135
136 $conn->close();
137 }
138
139 ?>